#! /bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src

# Test that a gettext() result comes out in the correct encoding, even when the
# same message from the same catalog file was already looked up in a locale with
# a different encoding.

# This test works only on glibc systems, because it relies on HAVE_LOCALE_NULL
# being set and on the notification by setlocale().
: ${GLIBC2=no}
test "$GLIBC2" = yes || {
  echo "Skipping test: not a glibc system"
  Exit 77
}

# This test works only on systems that have a de_DE.ISO-8859-1 and
# de_DE.UTF-8 locale installed.
LC_ALL=de_DE.ISO-8859-1 ../testlocale || {
  if test -f /usr/bin/localedef; then
    echo "Skipping test: locale de_DE.ISO-8859-1 not installed"
  else
    echo "Skipping test: locale de_DE.ISO-8859-1 not supported"
  fi
  Exit 77
}
LC_ALL=de_DE.UTF-8 ../testlocale || {
  if test -f /usr/bin/localedef; then
    echo "Skipping test: locale de_DE.UTF-8 not installed"
  else
    echo "Skipping test: locale de_DE.UTF-8 not supported"
  fi
  Exit 77
}

test -d in-sl-2 || mkdir in-sl-2
test -d in-sl-2/de_DE || mkdir in-sl-2/de_DE
test -d in-sl-2/de_DE/LC_MESSAGES || mkdir in-sl-2/de_DE/LC_MESSAGES

: ${MSGFMT=msgfmt}
${MSGFMT} -o in-sl-2/de_DE/LC_MESSAGES/tstprog.mo "$wabs_srcdir"/intl-setlocale-2.po

../intl-setlocale-2-prg || Exit 1

Exit 0
